package com.smartstate.ems.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartstate.ems.dto.PageDTO;
import com.smartstate.ems.entity.LoginLog;
import com.smartstate.ems.service.LoginLogService;
import com.smartstate.ems.util.StringUtils;
import com.smartstate.ems.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄活信
 */
@RestController
@RequestMapping("Log")
@Slf4j
@Api(tags = "登录日志管理器")
public class LoginLogController  {

    @Resource
    private LoginLogService loginLogSerice;

    @PostMapping("/list")
    @ApiOperation(value = "根据姓名或名称查询登录日志管理列表--分页", notes = "根据姓名或部门查询登录日志管理列表--分页")
    public Page<LoginLog> loadListByNameOrDept(@RequestBody PageDTO<LoginLog> pageDTO) {
        return loginLogSerice.getListByNameOrDept(pageDTO);
    }

    @PostMapping("/deleteLogByID")
    @ApiOperation(value = "根据日志数据ID删除数据", notes = "根据日志数据ID删除数据")
    public ResultVO<Boolean> deleteLogByID(@RequestParam String id) {
        if(StringUtils.isNotBlank(id)){
            return ResultVO.ok(loginLogSerice.deleteLogByID(id));
        }
        return  ResultVO.fail("参数缺失， 请输入参数");
    }

    @PostMapping("/batchDelete")
    @ApiOperation(value = "根据日志数据ID集合批量删除数据", notes = "根据日志数据ID集合批量删除数据")
    public ResultVO<Boolean> batchDeleteByIDs(@RequestBody List<String> ids) {
        if(ids.size()>0){
            return ResultVO.ok(loginLogSerice.batchDeleteByIDs(ids));
        }
        return  ResultVO.fail("参数缺失， 请输入参数");
    }



}
